
public class TransformHTML {
	String link = "";
	String txt;
	public TransformHTML (String html) {
		txt = removeTags(html);
	}
	
	 String removeTags (String html){
		int aStart=html.indexOf("href=");
		if (aStart >=0) {
			int aEnd=html.indexOf("\">[link]");
			link=html.substring(aStart+6, aEnd).replace("&amp;", "&");
		}
		html = html.replace( "<br>","[13]");
		html = html.replace("<p>","[15]");
		html = html.replace("[link]","[@]");
		//html = html.replace("+", "%2B");
		//html = html.replace(' ', '+');
		//html = html.replace("[link]", "");
		while(true) {
			int start = html.indexOf("<");
			int end = html.indexOf(">");
			if (start < 0 || end < 0) break;
			String htmlL=html.substring(0,start);
			//System.out.println(html.substring(start, start+5));
			//if (html.substring(start, start+5).equals("&lt;a")) htmlL+=link;
			String htmlR=html.substring(end+1);
			html=htmlL+htmlR;
		}
		html = html.replace( "[br]","<br>");
		html = html.replace("[p]","<p>");
		while (html.charAt(0)==' ') html = html.substring(1);
		return html;
	}
	 String getLink() {	return link; }
	 String toStr() {	return txt; }
	 static String format (String txt, String link) {
		 txt = txt.replace("[13],", "[13]");
		txt = txt.replace("[15],", "[13]");
		txt = txt.replace("[13]", "\n");
		txt = txt.replace("[15]", "\n\n");
		 return txt.replace("[@]", link);
	 }

}
